/*
 * Copyright (C) 2011 Johan Maasing johan at zoom.nu Licensed under the Apache
 * License, Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
 * or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package nu.zoom.bkkit.redlung;

import java.util.logging.Logger;

import org.bukkit.plugin.PluginDescriptionFile;

public class LogWrapper {
	private static String prefix;
	private static Logger log = Logger.getLogger("Minecraft");
	private static int loglevel;

	static void init(final PluginDescriptionFile descriptionFile,
			final Config config) {
		prefix = "[" + descriptionFile.getName() + "]["
				+ descriptionFile.getVersion() + "] - ";
		loglevel = config.getLogLevel();
		fine("Log level set to: " + loglevel);
	}

	static void entering(final String sourceClass, final String sourceMethod,
			final Object param) {
		if (loglevel > 1) {
			log.finest(prefix + "Entering " + sourceMethod + "(" + param + ")");
		}
	}

	static void exiting(final String sourceClass, final String sourceMethod,
			final Object param) {
		if (loglevel > 1) {
			log.finest(prefix + "Exiting " + sourceMethod);
		}
	}

	static void info(String message) {
		log.info(prefix + message);
	}

	static void fine(String message) {
		if (loglevel > 0) {
			log.fine(prefix + message);
		}
	}
}
